Getting Started with TensorFlow by 2016
Author:2016
Language: eng
Format: mobi, epub
Publisher: Packt Publishing
Building the training set
Import all the necessary libraries to our simulation:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf import pandas as pd
Note
Pandas is an open source, easy-to-use data structure, and data analysis tool for the Python programming language. To install it, type the following command:
sudo pip install pandas
We must define the parameters of our problem. The total number of points that we want to cluster is 1000 points:
num_vectors = 1000
The number of partitions you want to achieve by all initial:
num_clusters = 4
We set the number of computational steps of the k-means algorithm:
num_steps = 100
We initialize the initial input data structures:
x_values = [] y_values = [] vector_values = []
The training set creates a random set of points, which is why we use the random.normal NumPy function, allowing us to build the x_values and y_values vectors:
for i in xrange(num_vectors): if np.random.random() > 0.5: x_values.append(np.random.normal(0.4, 0.7)) y_values.append(np.random.normal(0.2, 0.8)) else: x_values.append(np.random.normal(0.6, 0.4)) y_values.append(np.random.normal(0.8, 0.5))
We use the Python zip function to obtain the complete list of vector_values:
vector_values = zip(x_values,y_values)
Then vector_values is converted into a constant, usable by TensorFlow:
vectors = tf.constant(vector_values)
We can see our training set for the clustering algorithm with the following commands:
plt.plot(x_values,y_values, 'o', label='Input Data') plt.legend() plt.show()
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8303)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6754)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6730)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6612)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6395)
Driving Data Quality with Data Contracts by Andrew Jones(6341)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6104)
Learning SQL by Alan Beaulieu(5997)
Weapons of Math Destruction by Cathy O'Neil(5783)
Big Data Analysis with Python by Ivan Marin(5371)
Data Engineering with dbt by Roberto Zagni(4370)
Solidity Programming Essentials by Ritesh Modi(4020)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3878)
Pandas Cookbook by Theodore Petrou(3586)
Blockchain Basics by Daniel Drescher(3298)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2909)
Feature Store for Machine Learning by Jayanth Kumar M J(2816)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2798)
Mastering Python for Finance by Unknown(2745)
